Skip to content

Add sdJwt presentation #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 26, 2024
Merged

Add sdJwt presentation #4

merged 8 commits into from
Aug 26, 2024

Conversation

Pflanzmann
Copy link

No description provided.

Copy link

@FelixRedAndroid FelixRedAndroid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Still left a couple of comments regarding unused code and stuff.


DocumentManagerSdJwt
.getAllDocuments()
// .filter { doc -> doc.vct == req.docType }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncommented code, remove?

.filterIsInstance<IssuedDocument>()
.filter { doc -> doc.docType == req.docType }
// .filter { doc -> doc.docType == req.docType }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncommented code, remove?

Comment on lines +44 to +45
//.filterKeys { it in credentialOffer.credentialConfigurationIdentifiers }
//.filterValues { credentialConfigurationFilter(it) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncommented code, remove?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still uncommented.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hab einen Kommentar drüber damit man weiß, dass das wieder rein muss

@@ -20,6 +20,7 @@ import eu.europa.ec.eudi.openid4vci.CredentialOfferRequestResolver
import eu.europa.ec.eudi.wallet.issue.openid4vci.CredentialConfigurationFilter.Companion.Compose
import eu.europa.ec.eudi.wallet.issue.openid4vci.CredentialConfigurationFilter.Companion.MsoMdocFormatFilter

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I also noticed, that the two fields MsoMdocFormatFilter and SdJwtFormatFilter in the CredentialConfigurationFilter are probably unused and can be removed.

Comment on lines +47 to +50
// val credentialConfigurationId =
// credentialIssuerMetadata.credentialConfigurationsSupported.filterValues { conf ->
// credentialConfigurationFilter(conf)
// }.keys.firstOrNull() ?: throw IllegalStateException("No suitable configuration found")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncommented code, remove?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still uncommented.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hab einen Kommentar drüber damit man weiß, dass das wieder rein muss

Comment on lines 274 to 275
// logger?.d(TAG, "Device Response to send (hex): ${Hex.toHexString(deviceResponse)}")
// logger?.d(TAG, "Device Response to send (cbor): ${CBOR.cborPrettyPrint(deviceResponse)}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncommented code, remove?

@@ -363,7 +438,7 @@ class OpenId4vpManager(
val responseUri =
(this.responseMode as ResponseMode.DirectPostJwt?)?.responseURI?.toString()
?: ""
val nonce = this.nonce
val nonce = this.nonce //TODO MAYBE THIS NONCE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a TODO. Is it still valid?

val key = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
KeyGeneratorImpl.getSigningKey(KeyGenerator.SigningKeyConfig(KeyProperties.AUTH_DEVICE_CREDENTIAL, 60))
} else {
throw Exception()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe adjust to something like this?
return@runBlocking ResponseResult.Failure(AndroidException("Build version to low."))

throw IllegalArgumentException()
}

val namespace = "eu.europa.ec.eudi.pid.1"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a constant.

Comment on lines 171 to 185
val headerString = credentials.split(".").first()
val headerJson = JSONObject(String(Base64.getUrlDecoder().decode(headerString)))
val keyString = headerJson.getJSONArray("x5c").getString(0).replace("\n", "")
println(keyString)

val pemString = "-----BEGIN CERTIFICATE-----\n" +
"${keyString}\n" +
"-----END CERTIFICATE-----"

val certificateFactory: CertificateFactory = CertificateFactory.getInstance("X.509")
val certificate =
certificateFactory.generateCertificate(ByteArrayInputStream(pemString.toByteArray())) as X509Certificate

val ecKey = ECKey.parse(certificate)
val jwtSignatureVerifier = ECDSAVerifier(ecKey).asJwtVerifier()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I've seen this code part before in this PR... ^^

Copy link

@FelixRedAndroid FelixRedAndroid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a rough review. Focused on code style / cleanup.
Looks good already, still left a few comments.

@@ -21,17 +22,23 @@ junit = "4.13.2"
junit-android = "1.1.5"
kotlin = "1.8.10"
ktor = "2.3.5"
#ktorClientSerialization = "2.3.6"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented lines, remove?

eudi-lib-jvm-siop-openid4vp-kt = { module = "eu.europa.ec.eudi:eudi-lib-jvm-siop-openid4vp-kt", version.ref = "eudi-lib-jvm-siop-openid4vp-kt" }
identity-credential = { module = "com.android.identity:identity-credential", version.ref = "identity-credential" }
json = { module = "org.json:json", version.ref = "json" }
junit = { module = "junit:junit", version.ref = "junit" }
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" }
ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktor" }
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
#ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktorClientSerialization" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented lines, remove?

@@ -149,6 +149,7 @@ dependencies {

// Ktor Android Engine
runtimeOnly libs.ktor.client.android
// implementation libs.ktor.client.serialization

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented lines, remove?

@@ -197,7 +200,9 @@ object EudiWallet {
* @throws IllegalStateException if [EudiWallet] is not firstly initialized via the [init] method
*/
fun deleteDocumentById(documentId: DocumentId): DeleteDocumentResult =
documentManager.deleteDocumentById(documentId)
documentManager.deleteDocumentById(documentId).apply {
if (this is DeleteDocumentResult.Success) DocumentManagerSdJwt.deleteDocument(documentId)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kurze Frage:
Waren unsere ID's jetzt gesynced, so dass das funktionieren kann?
(Oder nicht und wir müssen das noch einmal anpassen?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die Id´s sind nicht synced, aber wir gehen davon aus, dass wir nur ein SdJwt haben können und löschen das wenn irgendein Mdoc gelöscht wird. Das ist good enough würde ich sagen. Wir sollten in die Lib noch einen Check einbauen, dass man nicht mehr als ein Pid haben kann, damit hier nichts kaputt gehen kann

Comment on lines +44 to +45
//.filterKeys { it in credentialOffer.credentialConfigurationIdentifiers }
//.filterValues { credentialConfigurationFilter(it) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still uncommented.

Comment on lines +47 to +50
// val credentialConfigurationId =
// credentialIssuerMetadata.credentialConfigurationsSupported.filterValues { conf ->
// credentialConfigurationFilter(conf)
// }.keys.firstOrNull() ?: throw IllegalStateException("No suitable configuration found")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still uncommented.

} else {
val cborBytes = Base64.getUrlDecoder().decode(credential.credential)

logger?.d(TAG, "CBOR bytes: ${Hex.toHexString(cborBytes)}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only debug level, but I think we should remove this logger here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Der logger ist aus der originalen lib selbst, den haben wir nicht selbst hinzugefügt, aber ich kann ihn entfernen

return entry
}

private const val SIGNATURE_ALGORITHM = "SHA256withECDSA"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move up (line 23/24) to the other constants in this file?

val vpToken =
Base64.getUrlEncoder().withoutPadding()
.encodeToString(deviceResponse)
logger?.d(TAG, "VpToken: $vpToken")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this really be logged?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Der logger ist aus der originalen lib selbst, den haben wir nicht selbst hinzugefügt

@Pflanzmann Pflanzmann merged commit 143dea7 into workingBranch Aug 26, 2024
9 of 14 checks passed
@Pflanzmann Pflanzmann deleted the sdJwt2 branch August 26, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants